<template>
	<van-swipe  
	:height="getHeight" 
	class="my-swipe" 
	:autoplay="2000"
	:show-indicators="true" 
	indicator-color="#68ACF2"
	>
	
	  <van-swipe-item  @click="toProduct(item.goods_id)" v-for="item in bannerList" :key="item.goods_id">
		  <img class="swipe-img b-r-12" v-lazy="item.goods_thumb" />
	  </van-swipe-item>
	  
	</van-swipe>

</template>

<script>
	export default{
		data(){
			return {
				bannerList : []
			}
		},
		
		computed:{
			getHeight(){
				let windowW = document.documentElement.clientWidth - 24;
				return 475 / 1000 * windowW;
			}
		},
		methods:{
			toProduct(goodsId){
				this.$router.push({path:'details', query:{'goods_id' : goodsId}})
			}
		},
		created() {
			this.axios.get('/api_banner?bannerId=1').then((result) => {
				let {data} = result;
				if(data.code != 0){
					console.log('轮播图数据请求失败');
					return;
				};
				console.log(data); 
				return data;
			}).then((val) => {			
				this.bannerList =val.data
			})
		}
	}
</script>

<style scoped>
	.swipe-img{
		width:100%;
	}	
</style>
